//
//  LYCTabbarViewController.m
//  爱鲜蜂
//
//  Created by 廖易诚 on 16/6/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "LYCTabbarViewController.h"
#import "LYCHomeViewController.h"
#import "LYCBuyCarViewController.h"
#import "LYCMarketViewController.h"
#import "LYCMineViewController.h"
#import "LYCNavgationViewController.h"

@interface LYCTabbarViewController ()

@end

@implementation LYCTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupAllChildController];
}

// 添加子控制器
- (void)setupAllChildController {
    
    LYCHomeViewController *home = [[LYCHomeViewController alloc] init];
    UIImage *homeImage = [UIImage imageNamed:@"v2_home"];
    UIImage *homeSelImage = [UIImage imageNamed:@"v2_home_r"];
    [self addchildviewController:home title:@"首页" image:homeImage selImage:homeSelImage];
 
    
    LYCMarketViewController *market = [[LYCMarketViewController alloc] init];
    UIImage *marketImage = [UIImage imageNamed:@"v2_order"];
    UIImage *marketSelImage = [UIImage imageNamed:@"v2_order_r"];
    [self addchildviewController:market title:@"闪电超市" image:marketImage selImage:marketSelImage];
    
    LYCBuyCarViewController *buyCar = [[LYCBuyCarViewController alloc] init];
    UIImage *buyCarImage = [UIImage imageNamed:@"shopCart"];
    [self addchildviewController:buyCar title:@"购物车" image:buyCarImage selImage:nil];
    
    LYCMineViewController *mine = [[LYCMineViewController alloc] init];
    UIImage *mineImage = [UIImage imageNamed:@"v2_my"];
    UIImage *mineSelImage = [UIImage imageNamed:@"v2_my_r"];
    [self addchildviewController:mine title:@"我的" image:mineImage selImage:mineSelImage];
    

    
    
    
}

- (void)addchildviewController:(UIViewController *)controller title:(NSString  *)title image:(UIImage *)image selImage:(UIImage *)selImage {
    
    controller.tabBarItem.image = image;
    controller.tabBarItem.selectedImage = selImage;
    controller.title = title;
    
    LYCNavgationViewController *nav = [[LYCNavgationViewController alloc] initWithRootViewController:controller];
    [self addChildViewController:nav];
    
}



@end
